import 'package:application_with_bilibili/pages/login/password.dart';
import 'package:application_with_bilibili/pages/login/phone.dart';
import 'package:application_with_bilibili/pages/login/verify.dart';
import 'package:application_with_bilibili/pages/pageView/pageView.dart';
import 'package:application_with_bilibili/pages/pageView/pageViewBuilder.dart';
import 'package:application_with_bilibili/pages/pageView/pageViewFull.dart';
import 'package:application_with_bilibili/pages/pageView/pageViewKeepAlive.dart';
import 'package:application_with_bilibili/pages/pageView/pageViewSwiper.dart';
import 'package:flutter/material.dart';
import '../pages/tabs.dart';
import '../pages/flower.dart';
import '../pages/bird.dart';

// 定义路由map
Map<String, Function> routes = {
  "/": (context) => const Tabs(),
  "/bird": (context, {arguments}) => BirdPage(arguments: arguments),
  "/flower": (context) => const FlowerPage(),
  "/login/phone": (context) => const PhonePage(),
  "/login/verify": (context) => const VerifyPage(),
  "/login/password": (context) => const PasswordPage(),
  "/pageView": (context) => const PageViewPage(),
  "/pageViewBuilder": (context) => const PageViewBuilderPage(),
  "/pageViewFull": (context) => const PageViewFullPage(),
  "/pageViewSwiper": (context) => const PageViewSwiperPage(),
  "/pageViewKeepAlive": (context) => const PageViewKeepAlivePage(),
};

var myOnGenerateRoute = (RouteSettings settings) {
  final String? name = settings.name;
  final Function? pageContentBuilder = routes[name];
  if (pageContentBuilder != null) {
    if (settings.arguments != null) {
      // 带参数跳转
      final Route route = MaterialPageRoute(
          builder: (context) =>
              pageContentBuilder(context, arguments: settings.arguments));
      return route;
    } else {
      // 不带参数跳转
      final Route route =
          MaterialPageRoute(builder: (context) => pageContentBuilder(context));
      return route;
    }
  }
  return null;
};
